package org.homly.pc.action.scheme;

import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.homly.sql.SQLTool;
import org.homly.tool.StringTool;

public class GetSavedSchemeAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		String customerName = request.getParameter("cname");
		customerName = StringTool.unescape(customerName);
		String sql = " SELECT * FROM scheme WHERE scheme_customer_name='" + customerName + "'";
		List<HashMap<String, String>> list = SQLTool.query(sql);
		JSONArray jsonArray = JSONArray.fromObject(list);
		response.getWriter().print(jsonArray);
		return null;
	}
}
